//
//  RYCollectionView.swift
//  App_Profile
//
//  Created by 蒋晨成 on 2022/2/9.
//

import Foundation
import UICore
import UIKit

public final class RYCollectionView: UICollectionView {
    public init(layout: UICollectionViewLayout = UICollectionViewFlowLayout()) {
        super.init(frame: .zero, collectionViewLayout: layout)
        register(UICollectionViewCell.self, forCellWithReuseIdentifier: "UICollectionViewCell")
        registerCells([RYBaseCell.self, RYTitleCell.self, RYSwitchCell.self, RYTextCell.self, RYAvatarCell.self])
    }

    @available(*, unavailable)
    required init(coder _: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    @available(*, unavailable)
    public func setDataSource(_: UICollectionViewDataSource?) {
        fatalError("DO NOT CALL THIS")
    }
}

public extension RYCollectionView {
    func registerCells(_ cells: [CollectionViewCell.Type]) {
        cells.forEach { cell in
            register(cell.self, forCellWithReuseIdentifier: cell.cellID)
        }
    }
}
